const conn = require('../app/database')

class GoodsSkuModel {

  async getStockByGoodsSkuId(goodsSkuId) {
    const statement = `
      SELECT gs.goods_id goodsId, gs.stock stock FROM goods_sku gs WHERE id = ?; 
    `
    const [result] = await conn.execute(statement, [goodsSkuId])
    return result

  }

  async updateStockByGoodsSkuId(goodsSkuId, stock) {
    const statement = `
      UPDATE goods_sku SET stock = ? WHERE id = ?; 
    `
    const [result] = await conn.execute(statement, [stock, goodsSkuId])
    return result
  }

}

module.exports = new GoodsSkuModel()